﻿using RpcExtend.Model;
using RpcExtend.Model.DB;
using RpcHelper;
using SqlSugar;
using SqlSugarHelper;

namespace RpcExtend.DAL.Repository
{
    internal class ResourceShieldDAL : IResourceShieldDAL
    {
        private IRepository<ResourceShieldModel> _BasicDAL;
        public ResourceShieldDAL(IRepository<ResourceShieldModel> dal)
        {
            _BasicDAL = dal;
        }

        public ResourceShield Find(string[] keys, string path)
        {
            ISugarQueryable<ResourceShield>[] list = keys.ConvertAll(c =>
            {
                return this._BasicDAL.Queryable.Where(a => a.ShieKey == c && a.ResourcePath == path)
                .Select(a => new ResourceShield
                {
                    BeOverdueTime = a.BeOverdueTime,
                    Id = a.Id
                });
            });
            return _BasicDAL.Get(list, "SortNum desc");
        }

    }
}
